export default class timer1 extends Laya.Script {
    // 更多参数说明请访问: https://ldc2.layabox.com/doc/?nav=zh-as-2-4-0
    timer1=30;
    isplayer=false;
    owner=this.owner as Laya.Sprite;
    constructor() { super(); }
    onAwake(){
        this.timer2();
        Laya.stage.on("gamerover",this,function(){this.isplayer=false;this.timer1=31})
        Laya.stage.on("gamerover3",this,function(){this.isplayer=false;this.timer1=30})
        Laya.stage.on("start",this,function(){this.isplayer=true;})
        Laya.timer.loop(1000,this,this.timer2);
    }
    timer2(){
        if(!this.isplayer)return;
            this.timer1--;
            this.owner.text="倒计时:"+this.timer1;
            if(this.timer1<=0){
                Laya.stage.event("gamerover3");
            }
    }
}